import Vue from "vue";

let windowResize = {
    callBack: {},
    install() {
        const that = this
        Vue.directive('window-resize', {
            bind (el, binding, vnode, oldVnode) {
                console.log('v-window-resize');
                // console.log(this);
                window.onresize=function() {
                    if(that.callBack[window.location.pathname]){
                        that.callBack[window.location.pathname]()
                    } else {
                        console.warn('没有找到变化触发方法');
                    }
                }
            }
        })
        Vue.prototype.$WindowResizeCallBack = function (callBack) {
            that.callBack[window.location.pathname] = callBack
        }
    }
}

Vue.use(windowResize)